package com.apchernykh.rozhlasapp.player.fallback;


import com.apchernykh.rozhlasapp.utils.ConditionalLog;

import android.content.Context;

public class RozhlasFallbackPlayerAAC extends RozhlasFallbackPlayer {

	public RozhlasFallbackPlayerAAC(Context iContext, String iStreamUri) {
		super(iContext, iStreamUri);
	}

	
	// See AAC standard. 12-bit marker is on each frame start
	boolean tryRecognizeFrame(byte[] iBuffer, int iOffset) {
		if (iBuffer[iOffset] == (byte) 0xff) {
			ConditionalLog.d(toString(), "Searching for an AAC frame "
					+ iBuffer[iOffset + 1] + " " + iBuffer[iOffset + 7]);
			if ((iBuffer[iOffset + 1] & (byte) 0xF0) == (byte) 0xF0) {
				if ((iBuffer[iOffset + 7] == (byte) 0x21) || (iBuffer[iOffset + 7] == (byte) 0x01) ) {
					return true;
				}
			}
		}
		return false;
	}


}
